package com.qinggeng.project.api.controller;

import com.qinggeng.common.enums.JobUserTypeEnum;
import com.qinggeng.common.enums.UserTypeEnum;
import com.qinggeng.common.exception.CustomException;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.framework.web.page.TableDataInfo;
import com.qinggeng.project.api.dto.JobDliveryDTO;
import com.qinggeng.project.api.dto.JobMessageDTO;
import com.qinggeng.project.api.security.annotation.LoginRequired;
import com.qinggeng.project.api.security.utils.ApiUtils;
import com.qinggeng.project.system.domain.JobDlivery;
import com.qinggeng.project.system.domain.JobMessage;
import com.qinggeng.project.system.domain.vo.JobMessagePositionVO;
import com.qinggeng.project.system.domain.vo.JobMessageResumeVO;
import com.qinggeng.project.system.service.JobDliveryService;
import com.qinggeng.project.system.service.JobMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 招聘信息浏览记录Controller
 *
 * @author smallfish
 * @date 2020-12-24
 */
@RestController
@RequestMapping("/api/jobMessage")
@CrossOrigin("*")
public class ApiJobMessageController extends BaseController
{
    @Autowired
    private JobMessageService jobMessageService;



    /**
     * 消息列表
     */
    @GetMapping("/list")
     @LoginRequired(must = false,role = ApiUtils.DEFAULT_ROLE_USER)
    public AjaxResult get(JobMessageDTO jobMessage)
    {
        //个人看
        if (jobMessage.getUserType().equals(JobUserTypeEnum.RESUME_USER.getType())){
            List<JobMessagePositionVO> list = jobMessageService.listJobMessageByPositionUserId();
            return AjaxResult.success(list);
        }
        //公司看
        if (jobMessage.getUserType().equals(JobUserTypeEnum.POSITION_USER.getType())){
            List<JobMessageResumeVO> list = jobMessageService.listJobMessageByResumeUserId();
            return AjaxResult.success(list);
        }
         throw  new CustomException("传入正确的身份信息");
    }


}
